package com.zkh360.service.message.model;

/**
 * Created by hao.hu on 17-8-17.
 */
public class BaseResponse<T> {

	private boolean success;

	private String resultCode;

	private String resultMessage;

	private T result;
	
	public BaseResponse(){}

	public BaseResponse(boolean success, String resultCode, String resultMessage, T result){
		this.success = success;
		this.resultCode = resultCode;
		this.resultMessage = resultMessage;
		this.result = result;
	}


	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getResultCode() {
		return resultCode;
	}

	public void setResultCode(String resultCode) {
		this.resultCode = resultCode;
	}

	public String getResultMessage() {
		return resultMessage;
	}

	public void setResultMessage(String resultMessage) {
		this.resultMessage = resultMessage;
	}

	public T getResult() {
		return result;
	}

	public void setResult(T result) {
		this.result = result;
	}
	
	/**
	 * 操作成功.
	 * 
	 * @param resultCode
	 * @param resultMessage
	 * @param result
	 * @return
	 */
	public static <E> BaseResponse<E> sucess(String resultCode, String resultMessage, E result) {
		return new BaseResponse<E>(true, resultCode, resultMessage, result);
	}
	
	/**
	 * 操作失败.
	 * @param resultCode
	 * @param resultMessage
	 * @param result
	 * @return
	 */
	public static <E> BaseResponse<E> fail(String resultCode, String resultMessage, E result) {
		return new BaseResponse<E>(false, resultCode, resultMessage, result);
	}

}
